//
//  ByRoadRepairVC.m
//  hutouben_ios
//
//  Created by justiOS on 16/12/1.
//  Copyright © 2016年 mc. All rights reserved.
//

#import "ByRoadRepairVC.h"

// vc
#import "ByRepairOrderRoadVC.h"                 // 维修订单
#import "ByToRepairVC.h"                        // 报修

// view
#import "ByMenuView.h"

@interface ByRoadRepairVC ()
@property (nonatomic, strong) ByMenuView *menuView;
@property (nonatomic, assign) NSInteger curIndex;
@property (nonatomic, strong) ByRepairOrderRoadVC *orderVC;
@property (nonatomic, strong) ByToRepairVC *repairVC;
@end

@implementation ByRoadRepairVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addLeftBackBarButtonItem];
    [self createChildVC];
    [self createNaviMenuView];
    self.repairVC.view.frame = self.view.bounds;
    [self.view addSubview:self.repairVC.view];

}
#pragma mark ---创建视图
// 导航栏菜单视图
- (void)createNaviMenuView {
    _menuView = [[ByMenuView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    _menuView.titleAry = @[@"报修",@"订单"];
    __weak ByRoadRepairVC *that = self;
    _menuView.chooseBlock = ^(NSInteger index){
        NSLog(@"%li",(long)index);
        _curIndex = index;
        if (index == 1) {
            that.orderVC.view.frame = that.view.bounds;
            [that.view addSubview:that.orderVC.view];
        }else{
            that.repairVC.view.frame = that.view.bounds;
            [that.view addSubview:that.repairVC.view];
        }
    };
    self.navigationItem.titleView = _menuView;
}


//创建子视图控制器
- (void)createChildVC{
    
    self.orderVC = [[ByRepairOrderRoadVC alloc] init];
    self.repairVC = [[ByToRepairVC alloc] init];
    [self addChildViewController:self.orderVC];
    [self addChildViewController:self.repairVC];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
